import React from 'react';
import { connect } from 'umi';
// import groupBy from 'lodash/groupBy';
import { Form, Button, Input } from 'antd';
// import request from '@/utils/request';
// import styles from './index.less';

const QuickSearch = ({ form, pagination, setPagination, search, setSearch, setExpkeys = () => {} }) => {
    // const {
    //     url = '/api/dict/v1/getList',
    //     payload = {
    //         codes: urlType === 'salary' ? ['salaryFieldType'] : ['postMappingFieldType']
    //     }
    // } = urlMsg; // 基础数据请求
    // const { setSearchLoading } = data;
    const { getFieldDecorator } = form;
    // const Option = Select;
    // const [dict, setDict] = React.useState([]);

    // 搜索条件
    // const { salaryFieldType, postMappingFieldType } = groupBy(dict, 'code');
    // const prefixSelector = getFieldDecorator('searchType', {
    //     // initialValue: ''
    // })(
    //     <Select style={{ width: 135 }} placeholder="请选择" allowClear>
    //         {urlType === 'salary'
    //             ? salaryFieldType &&
    //               salaryFieldType.map(item => <Option value={item.dictValue}>{item.dictName}</Option>)
    //             : postMappingFieldType &&
    //               postMappingFieldType.map(item => <Option value={item.dictValue}>{item.dictName}</Option>)}
    //     </Select>
    // );
    // 获取数据
    // const getDict = async () => {
    //     const result = await request(url, {
    //         data: payload,
    //         method: 'POST'
    //     });
    //     if (result && result.code === 10000) {
    //         setDict(result.data);
    //     }
    // };
    // useEffect(() => {
    //     getDict();
    // }, []);

    const handleSearch = e => {
        e.preventDefault();
        setSearch(search + 1);
        setPagination({ ...pagination, current: 1 });
        setExpkeys([]);
    };
    return (
        <Form layout="inline" onSubmit={handleSearch} style={{ margin: '19px 0', float: 'left' }}>
            <Form.Item>
                {getFieldDecorator('searchName')(
                    <Input style={{ width: '100%' }} placeholder="请输入关键词" allowClear />
                )}
            </Form.Item>
            <Form.Item>
                <Button type="primary" htmlType="submit">
                    搜索
                </Button>
            </Form.Item>
        </Form>
    );
};

export default connect(({ user }) => ({ user: user.currentUser }))(QuickSearch);
